import {hrAjax as proFetch} from 'src/hrpub/common/utils/utils';
import { saveValidate } from 'src/hrpub/common/utils/utils';

export default async function saveNewData(param_str) {
    const {form, orgVal, transType, transState, editTable, func_type, pagecode} = this.props;
    let postData = {
        func_type,
        inout: transType,
        model: form.getAllFormValue('outbatchadd'),
        param_str,
        pk_org: orgVal.refpk,
        transstate: transState
    };

    await saveValidate(
        this.props,
        pagecode,
        'outbatchadd',
        [],
        'form',
        null,
        null
    );
    let callback = () => {
        return proFetch({
            url: '/nccloud/hrtrn/pub/RecordsPsntransterAddAction.do',
            body: postData,
        })
            .then((res) => {
                if (res.success) {
                    if (!res.data) {
                        editTable.setTableData('hi_psntranster1', {
                            rows: []
                        });
                    } else {
                        editTable.setTableData('hi_psntranster1', {
                            rows: res.data['hi_psntranster1'].rows
                        });
                    }
                    this.closeModal();
                }
            });
    };
    callback();
    /*this.props.validateToSave({
        outbatchadd: form.getAllFormValue('outbatchadd')
    }, callback, {}, 'form');*/
}
